package com.glsc.ngateway.platform.service.easyflow.strategy;

import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.easyflow.FlowFormRemindMain;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.easyflow.FlowFormRemindMainRepo;
import com.glsc.ngateway.platform.service.easyflow.AbstractEasyFlowStrategy;
import com.glsc.ngateway.platform.service.easyflow.dto.FlowDataDto;
import com.glsc.ngateway.platform.service.easyflow.dto.ParamDoTaskRespDto;
import com.glsc.ngateway.platform.service.easyflow.enums.ProcessDefineKeyEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 系统提醒
 *
 * @author zzp
 */
@Component
@Slf4j
public class RemindFlowServiceStrategy extends AbstractEasyFlowStrategy<FlowFormRemindMain> {

    @Resource
    private FlowFormRemindMainRepo flowFormRemindMainRepo;

    /**
     * 流程类型定义【重要区分】
     */
    @Override
    public String getProcessDefineKey() {
        return ProcessDefineKeyEnum.GWSystemRemind.getCode();
    }

    @Override
    public ParamDoTaskRespDto saveOrUpdateFormData(@NotNull FlowDataDto<FlowFormRemindMain> flowDataDto, String operatorAccount) {

        flowFormRemindMainRepo.save(flowDataDto.getFormMainData());

        ParamDoTaskRespDto paramDoTaskRespDto = new ParamDoTaskRespDto();
        return paramDoTaskRespDto;
    }

    @Override
    public FlowDataDto<FlowFormRemindMain> findFormDataByProcessId(@NotNull FlowDataDto<FlowFormRemindMain> flowDataDto, String operatorAccount) {
        FlowFormRemindMain remindMain = flowFormRemindMainRepo.findByProcessId(flowDataDto.getProcessId());
        flowDataDto.setFormMainData(remindMain);
        return flowDataDto;
    }

    @Override
    protected void processCreateAfterHandle(@NotNull FlowDataDto<FlowFormRemindMain> flowDataDto, String operatorAccount) {

    }


}
